package com.lcredu.seckill.controller;

import com.lcredu.seckill.rabbitmq.RabbitmqSender;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @author 黎长容
 * @date 2025-09-05 15:08
 */
@Controller
public class RabbitMQHandler {
    @Resource
    private RabbitmqSender rabbitmqSender;

    @RequestMapping("/mq")
    @ResponseBody
    private void mq() {
        rabbitmqSender.send("你好,MQ");
    }


    @RequestMapping("/mq/fanout")
    @ResponseBody
    private void fanout() {
        rabbitmqSender.sendByFanout("你好,Fanout");
    }

    @RequestMapping("/mq/direct01")
    @ResponseBody
    public void direct01() {
        rabbitmqSender.sendByDirectForSuccess("消息获取成功啦");
    }

    @RequestMapping("/mq/direct02")
    @ResponseBody
    public void direct02() {
        rabbitmqSender.sendByDirectForError("消息获取失败啦");
    }


    @RequestMapping("/mq/topic01")
    @ResponseBody
    public void topic01() {
        rabbitmqSender.sendByTopic01("这个消息只有queue1队列能接受");
    }

    @RequestMapping("/mq/topic02")
    @ResponseBody
    public void topic02() {
        rabbitmqSender.sendByTopic02("这个消息两个队列都能接收到");
    }

    @RequestMapping("/mq/header01")
    @ResponseBody
    public void header01() {
        rabbitmqSender.sendByHeader01("这条消息只有队列一能够接收");
    }

    @RequestMapping("/mq/header02")
    @ResponseBody
    public void header02() {
        rabbitmqSender.sendByHeader02("这条消息所有能够接收");
    }
}
